The Movie Toolbox allows your application to define functions that are invoked during specific operations. You can create a progress function that monitors the Movie Toolbox's progress on long operations, and you can create a cover function that allows your application to perform custom display processing.
See "Application-Defined Functions," which begins on Application-Defined Functions , for comprehensive details on these two types of functions.
Listing 14 shows two sample cover functions. Whenever a movie covers a portion of a window, the MyCoverProc function removes the covered region from the window's clipping region. When a movie uncovers a screen region, the MyUncoverProc function invalidates the region and adds it to the window's clipping region. By invalidating the region, this function causes the application to receive an update event, informing the application to redraw its window. The InitCoverProcs function initializes the window's clipping region and installs these cover functions.
Listing 14 Two sample movie cover functions
pascal OSErr MyCoverProc (Movie aMovie, RgnHandle changedRgn,
long refcon)
{
CGrafPtr mPort;
GDHandle mGD;
GetMovieGWorld (aMovie, &mPort, &mGD);
DiffRgn (mPort->clipRgn, changedRgn, mPort->clipRgn);
return noErr;
}
pascal OSErr MyUnCoverProc (Movie aMovie, RgnHandle changedRgn,
long refcon)
{
CGrafPtr mPort, curPort;
GDHandle mGD, curGD;
GetMovieGWorld (aMovie, &mPort, &mGD);
GetGWorld (&curPort, &curGD);
SetGWorld (mPort, mGD);
InvalRgn (changedRgn);
UnionRgn (mPort->clipRgn, changedRgn, mPort->clipRgn);
SetGWorld (curPort, curGD);
return noErr;
}
void InitCoverProcs (WindowPtr aWindow, Movie aMovie)
{
RgnHandle displayBounds;
GrafPtr curPort;
displayBounds = GetMovieDisplayBoundsRgn (aMovie);
if (displayBounds == nil) return;
GetPort (&curPort);
SetPort (aWindow);
ClipRect (&aWindow->portRect);
DiffRgn (aWindow->clipRgn, displayBounds, aWindow->clipRgn);
DisposeRgn( displayBounds );
SetPort (curPort);
SetMovieCoverProcs (aMovie, &MyUnCoverProc, &MyCoverProc, 0);
}